package cn.cstech.aijia.ui.base.fragments;

import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import cn.cstech.aijia.R;
import cn.cstech.aijia.ui.base.BaseFragment;

/**
 * Created with Android Studio.
 * Title:ShopMallFragment
 * Description:
 * Copyright:Copyright (c) 2014
 * Company:中国平安健康保险有限公司
 * Author:Alice
 * Date:15/9/5
 * Time:上午9:59
 * Version 1.0
 */
public class ShopMallFragment extends BaseFragment{
    @Override
    public View onCreateViewCustom(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.fg_shopmall, null);
        initViews(view);
        return view;
    }

    @Override
    public void onTitleBarCreate(){
        setTitleText("商城");
    }


    private WebView webview;
    private void initViews(View v){

        webview =(WebView) v.findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl("http://shop.50xue.com/mobile/");
        webview.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);// 使用当前WebView处理跳转
                return true;// true表示此事件在此处被处理，不需要再广播
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                // 有页面跳转时被回调
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                // 页面跳转结束后被回调
            }

            @Override
            public void onReceivedError(WebView view, int errorCode,
                                        String description, String failingUrl) {
                // 出错
            }
        });
    }
}
